<?php

namespace App\Admin\Controllers;

use App\enterpriseinfo;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class EnterpriseInfoController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\enterpriseinfo';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new enterpriseinfo());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('EnterpriseName', '企业名称');

        });

        $grid->column('EnterpriseName', __('企业名称'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Code', __('统一社会信用代码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('EnterpriseAddress', __('企业注册地址'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('RegistrationDate', __('注册时间'));
        $grid->column('BusinessTerm', __('营业期限'));
        $grid->column('Postcode', __('邮编'));
        $grid->column('Legal', __('法人'));
        $grid->column('Gender', __('性别'));
        $grid->column('SourceRelations', __('来源关系'));
        $grid->column('IDCODE', __('身份证号'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Validity', __('有效期'));
        $grid->column('StorageLocation', __('资料存放位置'));
        $grid->column('AmazonE', __('Amazon欧'));
        $grid->column('AmazonA', __('Amazon美'));
        $grid->column('AmazonJ', __('Amazon日'));
        $grid->column('eBay', __('eBay'));
        $grid->column('smt', __('速卖通'));
        $grid->column('lazada', __('lazada'));
        $grid->column('VAT-UK', __('VAT-UK'));
        $grid->column('VAT-DE', __('VAT-DE'));
        $grid->column('Remarks', __('其他备注'));



        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(enterpriseinfo::findOrFail($id));


        $show->field('EnterpriseName', __('企业名称'));
        $show->field('Code', __('统一社会信用代码'));
        $show->field('EnterpriseAddress', __('企业注册地址'));
        $show->field('RegistrationDate', __('注册时间'));
        $show->field('BusinessTerm', __('营业期限'));
        $show->field('Postcode', __('邮编'));
        $show->field('Legal', __('法人'));
        $show->field('Gender', __('性别'));
        $show->field('SourceRelations', __('来源关系'));
        $show->field('IDCODE', __('身份证号'));
        $show->field('Validity', __('有效期'));
        $show->field('StorageLocation', __('资料存放位置'));
        $show->field('AmazonE', __('Amazon欧'));
        $show->field('AmazonA', __('Amazon美'));
        $show->field('AmazonJ', __('Amazon日'));
        $show->field('eBay', __('eBay'));
        $show->field('smt', __('速卖通'));
        $show->field('lazada', __('lazada'));
        $show->field('VAT-UK', __('VAT-UK'));
        $show->field('VAT-DE', __('VAT-DE'));
        $show->field('Remarks', __('其他备注'));



        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new enterpriseinfo());


        $form->text('EnterpriseName', __('企业名称'));
        $form->text('Code', __('统一社会信用代码'));
        $form->text('EnterpriseAddress', __('企业注册地址'));
        $form->datetime('RegistrationDate', __('注册时间'));
        $form->text('BusinessTerm', __('营业期限'));
        $form->text('Postcode', __('邮编'));
        $form->text('Legal', __('法人'));
        $form->text('Gender', __('性别'));
        $form->text('SourceRelations', __('来源关系'));
        $form->text('IDCODE', __('身份证号'));
        $form->text('Validity', __('有效期'));
        $form->text('StorageLocation', __('资料存放位置'));
        $form->text('AmazonE', __('Amazon欧'));
        $form->text('AmazonA', __('Amazon美'));
        $form->text('AmazonJ', __('Amazon日'));
        $form->text('eBay', __('eBay'));
        $form->text('smt', __('速卖通'));
        $form->text('lazada', __('lazada'));
        $form->text('VAT-UK', __('VAT-UK'));
        $form->text('VAT-DE', __('VAT-DE'));
        $form->text('Remarks', __('其他备注'));



        return $form;
    }
}
